import { isPlainObject, camelCase } from "lodash";
// 下划线转驼峰
export const toCamelCase = (obj: any): any => {
  if (Array.isArray(obj)) {
    return obj.map(toCamelCase);
  } else if (isPlainObject(obj)) {
    return Object.keys(obj).reduce((result, key) => {
      const newKey = camelCase(key);
      result[newKey] = toCamelCase(obj[key]);
      return result;
    }, {} as Record<string, any>);
  }
  return obj;
}